package cn.getech.data.metadata.entity.permission;

import cn.getech.data.development.entity.permission.SysRoleDataPermission;
import cn.getech.data.metadata.entity.meta.CollectionTableField;
import lombok.Data;

@Data
public class CollectionTableFieldPermission extends SysRoleDataPermission {
    private String securityDataLevel;

    /**
     * 字段名称  由于树状图前端需要和上级字段名保持一致
     */
    private String tableName;

    public CollectionTableFieldPermission() {
    }

    public CollectionTableFieldPermission(CollectionTableField field, SysRoleDataPermission sysRoleDataPermission) {
        if (field != null) {
            setTableName(field.getFieldName());
            setSecurityDataLevel(field.getSecurityDataLevel());
            setDataId(field.getId());
        }
        if (sysRoleDataPermission != null) {
            setId(sysRoleDataPermission.getId());
            setQuery(sysRoleDataPermission.getQuery());
            setCreate(sysRoleDataPermission.getCreate());
            setUpdate(sysRoleDataPermission.getUpdate());
            setDelete(sysRoleDataPermission.getDelete());
            setAssign(sysRoleDataPermission.getAssign());
            setDecrypt(sysRoleDataPermission.getDecrypt());
            setExport(sysRoleDataPermission.getExport());
            setRoleId(sysRoleDataPermission.getRoleId());
            setDataType(sysRoleDataPermission.getDataType());
            setId(sysRoleDataPermission.getId());
            setWrite(sysRoleDataPermission.getWrite());
        }
    }

}
